#include <stdio.h>
#include <stdlib.h>
#include<malloc.h>

typedef int ElementType;
typedef struct Node *PtrToNode;
struct Node {
    ElementType Data;
    PtrToNode   Next;
};
typedef PtrToNode List;

List shuru(int N); 
void Print( List L ); 
void find(List L,int N);
List paixu( List L1, List L2 );

int main()
{
	int N;
	scanf("%d",&N);
    List L1, L2, L;
    L1 = shuru(N);
    L2 = shuru(N);
    L = paixu(L1, L2);
    find(L,N);
    return 0;
}

List shuru(int N){
	int m;
	List A=(List)malloc(sizeof(struct Node));
	A->Next=NULL;
	List p=A;
	for(int l=0;l<N;l++){
		scanf("%d",&m);
		List u=(List)malloc(sizeof(struct Node));
		p->Next=u;
		u->Data=m;
		p=u;
	} 
	p->Next=NULL;
	return A;
} 
List paixu( List L1, List L2 ){
	List m,n,k;
	List L=(List)malloc(sizeof(struct Node));
	L->Next=NULL;
	m=L1->Next;
	n=L2->Next;
	k=L;
	while(m!=NULL&&n!=NULL){
		if(m->Data==n->Data){
			k->Next=m;
			k=k->Next; 
			m=m->Next;
		}
		else if(m->Data<n->Data){
			k->Next=m;
			k=k->Next;
			m=m->Next;
		}
		else if(n->Data<m->Data){
			k->Next=n;
			k=k->Next;
			n=n->Next;
		}
	}
	if((k->Next==NULL)||m==NULL||n==NULL){
		L->Next==NULL;
	}
	return L;
}
void find(List L,int N){
	List o=L->Next;
	List q;
	for(int i=1;i<N;i++){
		o=o->Next;
	}
	printf("%d",o->Data);	
}





